Repository navigation
fix: allow sheet closing text in SVS recipes - #377
Conversation
|
Thanks for the fix and the clear write-up! The reported case works now, but
The root cause is that cursor = openEnd + 1;
while (true) {
cursor = skipSpace(text, cursor);
if (cursor >= text.length) fail(sourceName, "SVS_ROOT_UNCLOSED", "Source is missing </sheet>.", source.length);
if (text.startsWith("</sheet>", cursor)) break;
// existing recipe parsing, with closingBrace scanning up to text.length
}
const end = cursor + "</sheet>".length;
if (text.slice(end).trim().length > 0) fail(sourceName, "SVS_TRAILING", "Only trivia may follow </sheet>.", end);The loop only checks for Would you like to update the PR yourself, or would you prefer that we push the change on top of it? |
parseSvs searched the raw text for </sheet> before parsing, so a quoted recipe value containing that text was either taken as the close or, with lastIndexOf, guessed at. Check for the close tag only between recipes instead, since closingBrace already skips quoted text. A missing close now reports SVS_ROOT_UNCLOSED and a second close SVS_TRAILING, as on main. Co-authored-by: Sharky Wang <65097782+rponeawa@users.noreply.github.com>
|
Pushed your change on top as its own commit, with you as co-author. Your three inputs now behave as you described: the quoted I added the second and third to the existing test for the quoted case, and it fails on the |
|
Thanks for updating the PR so quickly and for adding the malformed-file cases to the test! The parser now finds the closing tag from the file structure instead of searching for it, which fixes the root cause. Merged, and it will ship in the next release. |
Authors who put a literal
</sheet>in a Text Template prompt getSVS_TRAILINGinstead of rendered text. A prompt showing someone how to write SVS markup is one case.The SVS parser found the first
</sheet>in the source, even when it was inside a quoted recipe value. It now looks for the closing tag between recipes, so quoted text is read as part of its value. One regression test round-trips the value through the SVS formatter. Another parses the recipe into a Text Template and renders the prompt. Both failed with the original parser and pass with the fix.Text after the closing tag, including a second
</sheet>, is still rejected withSVS_TRAILING. A sheet whose recipes are complete but that has no closing tag reportsSVS_ROOT_UNCLOSED, also when a quoted value contains</sheet>.Checks run:
pnpm checkpnpm test(1,105 passed, 21 skipped, 0 failed)Assisted by Claude/Codex.
Co-authored-by: Sharky Wang 65097782+rponeawa@users.noreply.github.com